class Weather {
	constructor(city){
		this.city = city
		this.key = "5eddf7bbf0cc4c7f8af1b71892bd2851"
	}
	async getLocationId(){
		return uni.request({
			url:`https://kn52qb7nm4.re.qweatherapi.com/geo/v2/city/lookup?location=${this.city}&key=${this.key}`,
			method:"GET"
		})
	}
	async getWeather(){
		const res = await this.getLocationId()
		const locationId = res.data.location[0].id
		return uni.request({
			url:`https://kn52qb7nm4.re.qweatherapi.com/v7/weather/now?location=${locationId}&key=${this.key}`,
			method:"GET"
		})
	}
	async get24hWeather(){
		const res = await this.getLocationId()
		const locationId = res.data.location[0].id
		return uni.request({
			url:`https://kn52qb7nm4.re.qweatherapi.com/v7/weather/24h?location=${locationId}&key=${this.key}`
		})
	}
}
export default Weather
